﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HNQXYJ.Model;
using HNQXYJ.DAL;

namespace HNQXYJ.BLL
{
    public class CityBLL
    {
        public List<HCity> GetCityListAll()
        {
            CityDAL cd = new CityDAL();
            List<HCity> list = cd.GetCitiesListAll();
            if (list.Count > 0)
            {
                return list;
            }
            else
            {
                return null;
            }
            
        }

         /// <summary>
        /// 根据获取的（从session中)权限码（城市表的selfcode）来获取去某个城市的基本信息
        /// </summary>
        /// <param name="selfCode">selfCode</param>
        /// <returns>HCity</returns>
        public HCity GetCityBySelfCode(string selfCode)
        {
            HCity city = new CityDAL().GetCityBySelfCode(selfCode);
            return city;
        }

         /// <summary>
        /// 添加城市
        /// </summary>
        /// <param name="city"></param>
        /// <returns></returns>
        public int AddCity(HCity city)
        {
            int res = new CityDAL().AddCity(city);
            return res;
        }

        /// <summary>
        /// 根据id删除城市
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteCityById(int id)
        {
            int res = new CityDAL().DeleteCityById(id);
            return res;
        }

        /// <summary>
        /// 根据id获取一个city对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCity GetCityById(int id)
        {
            HCity city = new CityDAL().GetCityById(id);
            return city;
        }

         /// <summary>
        /// 更新某个城市的数据
        /// </summary>
        /// <param name="city"></param>
        /// <returns></returns>
        public int UpdateCity(HCity city)
        {
            int res = new CityDAL().UpdateCity(city);
            return res;
        }
    }
}